<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>添加学生</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            color: #2c3e50;
            font-weight: bold;
        }

        input, select, textarea {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-weight: bold;
            width: 100%;
        }

        .btn-primary {
            background-color: #3498db;
            color: white;
        }

        .btn-link {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #3498db;
            text-decoration: none;
        }

        .error-message {
            color: #e74c3c;
            margin-bottom: 15px;
            text-align: center;
            padding: 10px;
            background-color: #fde8e8;
            border-radius: 4px;
            display: ${empty error ? 'none' : 'block'};
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>添加学生</h1>
        
        <div class="error-message">
            ${error}
        </div>
        
        <form action="student?action=add" method="post">
            <div class="form-group">
                <label for="studentNumber">学号:</label>
                <input type="text" id="studentNumber" name="studentNumber" 
                       value="${student.studentNumber}" required>
            </div>

            <div class="form-group">
                <label for="name">姓名:</label>
                <input type="text" id="name" name="name" 
                       value="${student.name}" required>
            </div>

            <div class="form-group">
                <label for="gender">性别:</label>
                <select id="gender" name="gender" required>
                    <option value="男" ${student.gender == '男' ? 'selected' : ''}>男</option>
                    <option value="女" ${student.gender == '女' ? 'selected' : ''}>女</option>
                </select>
            </div>

            <div class="form-group">
                <label for="age">年龄:</label>
                <input type="number" id="age" name="age" 
                       value="${student.age}" required min="15" max="100">
            </div>

            <div class="form-group">
                <label for="major">专业:</label>
                <select id="major" name="major" required>
                    <option value="计算机科学" ${student.major == '计算机科学' ? 'selected' : ''}>计算机科学</option>
                    <option value="软件工程" ${student.major == '软件工程' ? 'selected' : ''}>软件工程</option>
                    <option value="人工智能" ${student.major == '人工智能' ? 'selected' : ''}>人工智能</option>
                    <option value="数据科学" ${student.major == '数据科学' ? 'selected' : ''}>数据科学</option>
                    <option value="网络工程" ${student.major == '网络工程' ? 'selected' : ''}>网络工程</option>
                </select>
            </div>

            <div class="form-group">
                <label for="className">班级:</label>
                <input type="text" id="className" name="className" 
                       value="${student.className}" required>
            </div>

            <div class="form-group">
                <label for="admissionDate">入学日期:</label>
                <input type="date" id="admissionDate" name="admissionDate" 
                       value="${student.admissionDate}" required>
            </div>

            <div class="form-group">
                <label for="phone">电话:</label>
                <input type="tel" id="phone" name="phone" 
                       value="${student.phone}" pattern="[0-9]{11}">
            </div>

            <div class="form-group">
                <label for="email">邮箱:</label>
                <input type="email" id="email" name="email" 
                       value="${student.email}">
            </div>

            <div class="form-group">
                <label for="address">地址:</label>
                <textarea id="address" name="address" rows="3">${student.address}</textarea>
            </div>

            <button type="submit" class="btn btn-primary">添加学生</button>
        </form>

        <a href="student?action=list" class="btn-link">返回学生列表</a>
    </div>
</body>
</html> 